#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;
using LL = long long;
const int N = 1e5 + 10;

int n, m;
int q[N];
LL tr[N], tri[N];

int lowbit(int x){
    return (-x) & x;
}

void add(LL tr[], int x, LL k){
    for(int i = x; i <= n; i += lowbit(i)) tr[i] = (LL) tr[i] + k;
}

LL f(LL tr[], int x){
    LL res = 0;
    for(int i = x; i > 0; i -= lowbit(i)) res = (LL) res + tr[i];
    return res;
}

LL sum(int x){
    return (LL)f(tr, x) * (x + 1) - f(tri, x);
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);

    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i ++) scanf("%d", &q[i]);
    for(int i = 1; i <= n; i ++){
        int b = q[i] - q[i - 1];
        add(tr, i, b);
        add(tri, i, (LL)i * b);
    }

    for(int i = 0; i < m; i ++){
        char op[2];
        scanf("%s", op);

        if(op[0] == 'Q'){
            int l, r;
            scanf("%d%d", &l, &r);
            printf("%lld\n", sum(r) - sum(l - 1));
            
        }else{
            int l, r, d;
            scanf("%d%d%d", &l, &r, &d);
            add(tr, l, d), add(tr, r + 1, -d);
            add(tri, l, (LL) l * d), add(tri, r + 1, (LL) ((r + 1) * -d));
        }
    }

    return 0;
}